package cn.tedu._07springaop.aop;

import org.springframework.stereotype.Component;

//调用方法时不需要创建对象 而是交由框架帮忙创建对象
@Component

public class CalculatorImpl implements Calculator {
    @Override
    public int add(int x, int y) {
        // 手动抛出异常 用于测试后置通知是否执行
//        if (x > 0) {
//            throw new IllegalArgumentException("x不能大于0");
//        }
        int result = x + y;
        System.out.println("结果:" + result);
        return result;
    }

    @Override
    public int sub(int x, int y) {
        int result = x - y;
        System.out.println("结果:" + result);
        return result;
    }

    @Override
    public int mul(int x, int y) {
        int result = x * y;
        System.out.println("结果:" + result);
        return result;
    }

    @Override
    public int div(int x, int y) {
        int result = x / y;
        System.out.println("结果:" + result);
        return result;
    }
}
